<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>奔跑的火柴人</title>
    <style>
        body{
            background-color: #000;
        }

        .container{
            width: 100%;
            height: 300px;
            margin: 50px; 
        }
        .person{
            left: 150px;
            top: 160px;
            position: absolute;
            animation: play 3s infinite ease-in;
        }
        .head{
            width: 30px;
            height: 30px;
            position: absolute;
            border-radius: 50%;
            border: 5px solid  #fff;
            top: -30px;
            left: -6px;
            animation: bob 2s infinite alternate;
        }
        .torso{
            width: 0;
            height: 60px;
            position: absolute;
            border-left: 5px solid #fff;
            top:15px;
            left:0px;
        }
        .person .part{
            position: absolute;
            left: 0px;
            top: 15px;
        }
        .person .part.arm{
            width: 40px;
            height: 45px;
            border-left: 5px solid #fff;
            border-bottom: 5px solid #fff;
            position: absolute;
            top: 15px;
            right: 300px;
            transform-origin: 0% 0% 0px; 
            /*胳膊摆动  */
            animation: pubm 1s infinite ease-in-out;   
        }
        .person .part.arm.one{
            transform: rotate3d(0,0,1,80deg);
        }
        .person .part.arm.two{
            transform: rotate3d(0,0,1,-80deg);
            /* 因为会动两个胳膊 ，所以延迟*/
            animation-delay: .5s;
        }
        .person .part.leg{
            width: 60px;
            height: 60px;
            border-right: 5px solid #fff;
            border-top: 5px solid #fff;
            position: absolute;
            top: 75px;
            transform-origin: 0% 0% 0px;       
            animation: run 1s infinite ease-in-out;
        }
        .person .part.leg.one{
            transform: rotate3d(0,0,1,100deg);
            
        }
        .person .part.leg.two{
            transform: rotate3d(0,0,1,-10deg);
            animation-delay: .5s;
        }
        /* 火柴人动起来 */
        /* 头部动画 */
        @keyframes bob{
            0%{
               transform: rotate3d(0,0,1,5deg);
            }
            25%{
                transform: rotate3d(0,0,1,-30deg) skew(15deg,0deg);
            }
            50%{
                transform: rotate3d(0,0,1,5deg);
            }
            75%{
                transform: rotate3d(0,0,1,-30deg) skew(15deg,0deg);
            }
            100%{
                transform: rotate3d(0,0,1,20deg)skew(-15deg,0deg);
            }   
        }
        /* 胳膊动 */
        @keyframes pubm{
            0%{
               transform: rotate3d(0,0,1,80deg);
            }
            50%{
                transform: rotate3d(0,0,1,-70deg);
            }
            100%{
                transform: rotate3d(0,0,1,80deg);
            }
        }
        /* 腿动 */
        @keyframes run{
            0%{
               transform: rotate3d(0,0,1,-5deg);
            }
            50%{
                transform: rotate3d(0,0,1,150deg);
            }
            100%{
                transform: rotate3d(0,0,1,-5deg);
            }
        }
        /* 跑起来 */
        @keyframes play{
            0%{
                transform: translate(-100px, 0px);
            }
            100%{
                transform: translate(1800px, 0px);
            }
        }
    </style>
</head>
<body>
    <!-- 绘制火柴人 -->
    <div class="container">
        <div class="person">
            <div class="head"></div>
            <div class="part arm one"></div>
            <div class="part arm two"></div>
            <div class="torso"></div>
            <div class="part leg one"></div>
            <div class="part leg two"></div>
        </div>
    </div>
</body>
</html>